package cn.structure.edp;

import cn.structure.ClassEntity;
import cn.structure.MethodEntity;

import java.util.Objects;

public class Redirection extends EdpEntity {
    private ClassEntity redirector;
    private MethodEntity operation;
    private ClassEntity redirectee;
    private MethodEntity operation2;

    public Redirection(ClassEntity redirector, MethodEntity operation, ClassEntity redirectee, MethodEntity operation2) {
        super();
        this.redirector = redirector;
        this.operation = operation;
        this.redirectee = redirectee;
        this.operation2 = operation2;
    }

    public enum Role {
        redirector, operation, redirectee, operation2
    }

    public ClassEntity getRedirector() {
        return redirector;
    }

    public void setRedirector(ClassEntity redirector) {
        this.redirector = redirector;
    }

    public MethodEntity getOperation() {
        return operation;
    }

    public void setOperation(MethodEntity operation) {
        this.operation = operation;
    }

    public ClassEntity getRedirectee() {
        return redirectee;
    }

    public void setRedirectee(ClassEntity redirectee) {
        this.redirectee = redirectee;
    }

    public MethodEntity getOperation2() {
        return operation2;
    }

    public void setOperation2(MethodEntity operation2) {
        this.operation2 = operation2;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Redirection{\n\t");
        sb.append(super.toString());
        sb.append("\n\t\"redirector\":")
                .append(redirector);
        sb.append(",\n\t\"operation\":")
                .append(operation);
        sb.append(",\n\t\"redirectee\":")
                .append(redirectee);
        sb.append(",\n\t\"operation2\":")
                .append(operation2);
        sb.append("\n}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        Redirection that = (Redirection) o;
        return Objects.equals(redirector, that.redirector) &&
                Objects.equals(operation, that.operation) &&
                Objects.equals(redirectee, that.redirectee) &&
                Objects.equals(operation2, that.operation2);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), redirector, operation, redirectee, operation2);
    }
}
